package com.ruoyi.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.system.domain.CostRequest;
import com.ruoyi.system.domain.vo.zbg.MonthlyRepairDataVo;
import com.ruoyi.system.domain.vo.zbg.MonthlyRepairTotal;
import com.ruoyi.system.domain.vo.zbg.RepairDateVo;
import com.ruoyi.system.domain.zbg.AnnualPlanData;
import com.ruoyi.system.domain.zbg.MonthlyRepairData;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface MonthlyRepairDataMapper extends BaseMapper<MonthlyRepairData> {




    //    int insert(@Param("monthlyRepairData") MonthlyRepairData monthlyRepairData);
    AnnualPlanData selectByYear(int currentYear);

    @Insert("<script>" +
            "INSERT INTO monthly_repair_data (" +
            "district, " +
            "line, " +
            "line_month, " +
            "home, " +
            "home_month, " +
            "ji_ke, " +
            "ji_ke_month, " +
            "power, " +
            "power_month, " +
            "wireless, " +
            "wireless_month, " +
            "maintenance, " +
            "maintenance_month, " +
            "monthly_target, " +
            "monthly_accumulated, " +
            "monthly_progress, " +
            "year, " +
            "month" +
            ") " +
            "VALUES (" +
            "#{monthlyRepairData.district}, " +
            "#{monthlyRepairData.line}, " +
            "#{monthlyRepairData.lineMonth}, " +
            "#{monthlyRepairData.home}, " +
            "#{monthlyRepairData.homeMonth}, " +
            "#{monthlyRepairData.jiKe}, " +
            "#{monthlyRepairData.jiKeMonth}, " +
            "#{monthlyRepairData.power}, " +
            "#{monthlyRepairData.powerMonth}, " +
            "#{monthlyRepairData.wireless}, " +
            "#{monthlyRepairData.wirelessMonth}, " +
            "#{monthlyRepairData.maintenance}, " +
            "#{monthlyRepairData.maintenanceMonth}, " +
            "#{monthlyRepairData.monthlyTarget}, " +
            "#{monthlyRepairData.monthlyAccumulated}, " +
            "#{monthlyRepairData.monthlyProgress}, " +
            "#{monthlyRepairData.year}, " +
            "#{monthlyRepairData.month}" +
            ") " +
            "ON DUPLICATE KEY UPDATE " +
            "line = VALUES(line), " +
            "line_month = VALUES(line_month), " +
            "home = VALUES(home), " +
            "home_month = VALUES(home_month), " +
            "ji_ke = VALUES(ji_ke), " +
            "ji_ke_month = VALUES(ji_ke_month), " +
            "power = VALUES(power), " +
            "power_month = VALUES(power_month), " +
            "wireless = VALUES(wireless), " +
            "wireless_month = VALUES(wireless_month), " +
            "maintenance = VALUES(maintenance), " +
            "maintenance_month = VALUES(maintenance_month), " +
            "monthly_target = VALUES(monthly_target), " +
            "monthly_accumulated = VALUES(monthly_accumulated), " +
            "monthly_progress = VALUES(monthly_progress)" +
            "</script>")
    int saveOrUpdate(@Param("monthlyRepairData") MonthlyRepairData monthlyRepairData);


//    List<MonthlyRepairDataVo> getMonthlyRepairDataByRequest(@Param("costRequest") CostRequest costRequest);
    /**
     * 查询年度维修费使用情况
     * @param year 年份
     * @Param district 区域
     * @return
     */


    MonthlyRepairTotal selectByYearAndDistrict(@Param("year") Integer year,@Param("district") String district);
    /**
     * 查询月度维修费使用情况
     * @param year 年份
     * @Param district 区域
     * @Param month 月份
     * @return
     */
    MonthlyRepairData selectByYearAndMonthAndDistrict(@Param("year") Integer year, @Param("month") Integer month, @Param("district") String district);
}